home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7517 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  50 lines

  1. Path: news.bridge.net!news
  2. From: David Byrden <100101.2547@compuserve.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Assembler / C++ class not working!
  5. Date: 23 Feb 1996 18:10:59 GMT
  6. Organization: self-employed
  7. Message-ID: <4gkvvj$b5d@news.bridge.net>
  8. References: <4gj6pb$gb3@nntp.ucs.ubc.ca>
  9. NNTP-Posting-Host: ppp-mia3-116.bridge.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
  14.  
  15.  
  16. >>>>>
  17. class MyClass {
  18.         public:
  19.         unsigned int a;
  20.         void function();
  21.         };
  22. void MyClass::function () {
  23.         asm {
  24.                 mov ax,a
  25.                   ... Do stuff ...
  26.                 }
  27.         }
  28.  
  29.  
  30. For some reason, this will not compile!!!
  31. <<<<<
  32.  
  33.  
  34.   The assembler is unable to get you the machine address of "a" because 
  35. there IS no single "a". Instead, "a" is a class member and every MyClass 
  36. object contains an "a".
  37.  
  38.   You will have to provide the address of a MyClass, and add the offset 
  39. of an "a" from that.
  40.  
  41.   The C++ syntax for getting the offset is
  42.  
  43.             & MyClass::a
  44.  
  45. I don't know whether your assembler will understand uit.
  46.  
  47.                                David
  48.  
  49.  
  50.